package com.swgk.core.recyclerview.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.swgk.core.BR;
import com.swgk.core.R;
import com.swgk.core.recyclerview.entity.BaseAreaEntity;

import java.util.List;

public class BaseProvinceAdapter extends BaseRecycleAdapter<BaseAreaEntity<List<BaseAreaEntity<List<BaseAreaEntity>>>>> {
    boolean isShowSimple;
    private ImageView imageView;
    private boolean isShowGou;


    public void setShowSimple(boolean showSimple) {
        isShowSimple = showSimple;
    }

    public BaseProvinceAdapter(Context context, List<BaseAreaEntity<List<BaseAreaEntity<List<BaseAreaEntity>>>>> datas, int tag) {
        super(context, tag, datas);

    }

    @Override
    public void convert(ItemViewHolder holder, final BaseAreaEntity<List<BaseAreaEntity<List<BaseAreaEntity>>>> entity) {
        holder.setBinding(BR.viewModel, entity);
        TextView tvName = holder.getItem().findViewById(R.id.tv_name);
        imageView = holder.getItem().findViewById(R.id.select_img);
        if (isShowGou) {
            imageView.setVisibility(View.VISIBLE);
            tvName.setBackground(context.getResources().getDrawable(R.drawable.only_select_province_item_bg));
        } else {
            tvName.setBackground(context.getResources().getDrawable(R.drawable.select_province_item_bg));
        }
//        if (isShowSimple) {
        tvName.setText(TextUtils.isEmpty(entity.getSimpleName()) ? entity.getName() : entity.getSimpleName());
   /*     } else {
            tvName.setText(entity.getName());
        }*/
        if (holder.getItem().isSelected()) {
            tvName.getPaint().setFakeBoldText(true);
        } else {
            tvName.getPaint().setFakeBoldText(false);
        }
    }

    public void setImgStyle() {
        isShowGou = true;
    }
}
